<?php
/* 
 * Copyright (c) 2018-2021   All rights reserved.
 * 
 * 创建时间：2021-11-02 14:45
 *
 * 项目：rm  -  $  - inputtypes.php
 *
 * 作者：liwei 
 */

namespace lev\widgets\inputs;

use Lev;
use lev\helpers\SettingsHelper;
use lev\widgets\inputs\tablesForm;
use lev\widgets\inputs\inputtypes\_InputTypes;
use lev\widgets\inputs\inputtypes\navsType;
use lev\widgets\inputs\inputtypes\selectSearchType;
use lev\widgets\inputs\inputtypes\selectType;
use lev\widgets\inputs\inputtypes\slidesType;
use lev\widgets\inputs\inputtypes\tablesFormType;
use lev\widgets\inputs\inputtypes\uploadattachType;
use lev\widgets\inputs\inputtypes\uploadimgType;
use lev\widgets\inputs\inputtypes\wangeditorType;

!defined('INLEV') && exit('Access Denied LEV');


class inputtypes extends _InputTypes
{

    public static function wangeditorType($name, $value, $v)
    {
        //return parent::wangeditorType($name, $value, $v); // TODO: Change the autogenerated stub
        return wangeditorType::input($name, $value, $v);
    }

    public static function tablesFormType($name, $value, $v)
    {
        //return parent::tablesFormType($name, $value, $v); // TODO: Change the autogenerated stub
        return tablesFormType::inputInfo($name, $value, $v);
    }

    public static function tabletrFormType($name, $value, $v)
    {
        //return parent::tabletrFormType($name, $value, $v); // TODO: Change the autogenerated stub
        return tablesFormType::inputInfoOneTr($name, $value, $v);
    }

    public static function tableSubnavFormType($name, $value, $v)
    {
        //return parent::tableSubnavFormType($name, $value, $v); // TODO: Change the autogenerated stub
        return tablesFormType::inputInfoSubnav($name, $value, $v);
    }

    public static function selectSearchType($name, $value, $v)
    {
        //return parent::selectSearchType($name, $value, $v); // TODO: Change the autogenerated stub

        return selectSearchType::input($name, $value, $v);
    }

    public static function navsType($name, $value, $v)
    {
        //return parent::navsType($name, $value, $v); // TODO: Change the autogenerated stub
        return navsType::input($name, $value, $v);
    }

    public static function tablesnavType($name, $value, $v)
    {
        //return parent::tablesnavType($name, $value, $v); // TODO: Change the autogenerated stub
        return navsType::input2($name, $value, $v);
    }

    public static function slidesType($name, $value, $v)
    {
        //return parent::slidesType($name, $value, $v); // TODO: Change the autogenerated stub
        return slidesType::input($name, $value, $v);
    }

    public static function uploadattachType($name, $value, $v, $isimg = null)
    {
        return uploadattachType::input($name, $value, $v, $isimg); // TODO: Change the autogenerated stub
    }
    public static function uploadimgType($name, $value, $v)
    {
        return uploadimgType::input($name, $value, $v); // TODO: Change the autogenerated stub
    }

    public static function selectscodeType($name, $value, $v)
    {
        //return parent::selectscodeType($name, $value, $v); // TODO: Change the autogenerated stub
        return static::selectsType($name, $value, $v);
    }

    public static function selectcodeType($name, $value, $v)
    {
        //return parent::selectcodeType($name, $value, $v); // TODO: Change the autogenerated stub
        return static::selectType($name, $value, $v);
    }

    public static function selectType($name, $value, $v)
    {
        //return parent::selectType($name, $value, $v); // TODO: Change the autogenerated stub
        return selectType::input($name, $value, $v);
    }

    public static function selectsType($name, $value, $v)
    {
        //return parent::selectsType($name, $value, $v); // TODO: Change the autogenerated stub
        $name = tablesForm::inputName($name, $v);

        $_item = inputsFormWidget::getSelectItem($v);

        $input = static::bigBtn($name);
        $input.= '<div class="checkbox-list bigObjx">';

        $value && !is_array($value) && $value = json_decode($value, true);
        $values = $value ? array_flip($value) : [];
        foreach ($_item as $vid => $vtitle) {
            $ckd    = isset($values[$vid]) ? ' checked' : '';
            $input .= '<label><input type="checkbox" name="'.$name.'[]" value="'.$vid.'"'.$ckd.'>'.$vtitle.'</label>';
        }
        return $input .'</div>';
    }

    public static function buttonsType($name, $value, $v)
    {
        //return parent::buttonsType($name, $value, $v); // TODO: Change the autogenerated stub

        $htm = '';
        if ($v = Lev::getSettings(Lev::getSettings($v['settings'], 'set_buttons'))) {
            $v = reset($v);
            $icon = SettingsHelper::navIcon(0, $v['logoupload'], true);
            $target = SettingsHelper::navTarget($v['target'], $v['link']);
            if ($v['target'] != 99) {
                $v['link'] = Lev::toRoute([$v['link']]);
                $link = $v['link'] ? '" href="' . $v['link'] : '';
            }else {
                $link = '';
            }
            switch ($v['ShowType']) {
                case 1 : $name = $v['name']; break;
                case 2 : $name = $icon . $v['name']; break;
                default: $name = $icon; break;
            }
            $htm = '<a class="button button-fill color-'.$v['bgcolor'].$target.$link.'">'.$name.'</a>';
        }
        return '<div class="settings-buttons-box">'.$htm.'</div>';
    }
}